﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using text.Utils;

namespace text
{
    public partial class Reply : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //往回复表插入一条数据
            int loginUser = 0;//session
            int commentId = Convert.ToInt32(Request["cid"]);
            string detail = TextBox1.Text.Trim();
            //insert
            // int userId=从session里拿
            DataRow userRow = (DataRow)Session["User"];
            int userid = Convert.ToInt32(userRow["id"]);
        
            
            string sql = string.Format("insert into replys values ({0},{1},'{2}','{3}')", userid, commentId, detail, DateTime.Now);
            //插入insert
            int flag = DbHelper.Execute(sql);
            if (flag > 0)
            {
                Response.Write("<script>alert('回复成功');</script>");

            }
       
            //2)重新定向到当前页面内
   
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> window.opener.location.reload();window.close();</script>");

        }
    }
}